﻿Imports Runa.Scripting.ScriptingHost
Imports Runa.Resources.ContentManagers
Imports System.Text

Namespace Global.Runa.UI.Metadata

    Public Class RubyStringConverter
        Inherits TypeConverter

        Private Shared m_scriptConverter As ScriptTask

        Shared Sub New()
            m_scriptConverter = New ScriptTask("ConvertString.rb")            
        End Sub

        Public Sub New(g As Game)
            MyBase.New(g)
        End Sub

        Public Overrides Function ConvertFromInvariantString(ByVal text As String) As Object
            m_scriptConverter.Script = "var = " + ChrW(34) + text + ChrW(34) + vbCrLf _
                                      + "var"
            m_scriptConverter.Execute()
            Return m_scriptConverter.Result.ToString()
        End Function

        Public Overrides Function ConvertFromString(text As String) As Object
            Return ConvertFromInvariantString(text)
        End Function

    End Class

End Namespace